package com.xbongbong.paas.config.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * 工作流任务流转日志表状态
 * @author 魏荣杰
 *
 */
@Getter
public enum WorkflowTaskLogStatusEnum {
    /**
     * 通过
     */
    PASS(1,"pass", "通过", "完成"),
    /**
     * 中止
     */
    SUSPEND(2, "suspend", "中止", "中止"),
    /**
     * 等待
     */
    WAIT(3, "wait", "等待", "进行中"),
    /**
     * 失败
     */
    FAIL(4, "fail", "失败", "失败"),
    /**
     * 未知
     */
    UNKNOWN(404, "unknown", "未知", "未知"),
    ;

    private final Integer type;

    private final String alias;

    private final String memo;

    private final String taskMemo;

    WorkflowTaskLogStatusEnum(Integer type, String alias, String memo, String taskMemo) {
        this.type = type;
        this.alias = alias;
        this.memo = memo;
        this.taskMemo = taskMemo;
    }

    public static WorkflowTaskLogStatusEnum getByCode(Integer code) {
        for (WorkflowTaskLogStatusEnum cacheCode : values()) {
            if (Objects.equals(cacheCode.getType(), code)) {
                return cacheCode;
            }
        }
        return UNKNOWN;
    }
}
